import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/LoginView'

Vue.use(VueRouter)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routes = [{
    path: '/login',
    name: 'login',
    component: Login
},
{
    path: '/home',
    name: 'home',
    redirect: '/home/tableManagementView',
    component: () =>
        import('../views/HomeView'),
    children: [{
        path: '/home/tableManagementView',
        name: 'tableManagementView',
        component: () =>
            import('../views/TableManagementView'),
        meta: { title: ['餐桌管理'] }
    },
    {
        path: '/home/foodManagementView',
        name: 'foodManagementView',
        component: () =>
            import('../views/FoodManagementView'),
        meta: { title: ['菜品管理'] }
    },
    {
        path: '/home/orderManagementView',
        name: 'orderManagementView',
        component: () =>
            import('../views/OrderManagementView'),
        meta: { title: ['点菜管理'] }
    },
    {
        path: '/home/memberManagementView',
        name: 'memberManagementView',
        component: () =>
            import('../views/MemberManagementView'),
        meta: { title: ['会员管理'] }
    },
    {
        path: '/home/cashierView',
        name: 'cashierView',
        component: () =>
            import('../views/CashierView'),
        meta: { title: ['收银'] }
    },
    {
        path: '/home/personnelManagementView',
        name: 'personnelManagementView',
        component: () =>
            import('../views/PersonnelManagementView'),
        meta: { title: ['人员管理'] }

    }
    ]
},
{
    path: '/',
    redirect: '/login'
},
{
    path: '/',
    redirect: '/home/personnelManagementView'
}
]

const router = new VueRouter({
    routes
})

export default router